#ifndef PLATFORM_H
#define PLATFORM_H

#include <QCoreApplication>



#if defined(Q_OS_WIN32)   //win

#define FIXLOCALPATH_R(x) x            //只读本地文件路径
#define FIXLOCALPATH_W(x) x            //读写本地文件路径
//#define FIXLOCALPATH_R(x) (QString("file:") + x)
//#define FIXLOCALPATH_R(x) (QString("qrc:/") + x)
//#define FIXLOCALPATH_W(x) (QString("file:") + x)

#define FIXRESOURCEPATH_R(x) (QString(":/") + x)     //只读资源路径转换
#define FIXRESOURCEURL_R(x) (QString("qrc:/") + x)   //只读资源URL转换


#include <windows.h>
//一个实例运行
bool checkOne(LPCWSTR lpName = L"Pleafles");



#elif defined(Q_OS_ANDROID)   //android

#define FIXLOCALPATH_R(x) (QString("assets:/") + x)      //只读本地文件路径
#define FIXLOCALPATH_W(x) x                //读写本地文件路径

#define FIXRESOURCEPATH_R(x) (QString(":/") + x)         //只读资源路径转换
#define FIXRESOURCEURL_R(x) (QString("qrc:/") + x)       //只读资源URL转换


//0:横屏(顺时针90度);1:正常;
int getScreenOrientation();
void setScreenOrientation(int orient);

//设置和取消屏幕常亮
void keepScreenWake(bool bOn);


//自定义 控制台输出
void customAndroidMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);



#elif defined(Q_OS_MACOS)

#define FIXLOCALPATH_R(x) (QCoreApplication::applicationDirPath() + "/" + x)            //只读本地文件路径
#define FIXLOCALPATH_W(x) (QCoreApplication::applicationDirPath() + "/" + x)            //读写本地文件路径

#define FIXRESOURCEPATH_R(x) (QString(":/") + x)     //只读资源路径转换
#define FIXRESOURCEURL_R(x) (QString("qrc:/") + x)   //只读资源URL转换



#elif defined(Q_OS_IOS)

#define FIXLOCALPATH_R(x) (QCoreApplication::applicationDirPath() + "/" + x)            //只读本地文件路径
#define FIXLOCALPATH_W(x) (QCoreApplication::applicationDirPath() + "/" + x)

#define FIXRESOURCEPATH_R(x) (QString(":/") + x)     //只读资源路径转换
#define FIXRESOURCEURL_R(x) (QString("qrc:/") + x)   //只读资源URL转换



#elif defined(Q_OS_LINUX)   //linux,必须在Q_OS_ANDROID之后,因为Android环境会即将Linux也定义


#define FIXLOCALPATH_R(x) x            //只读本地文件路径
#define FIXLOCALPATH_W(x) x            //读写本地文件路径

#define FIXRESOURCEPATH_R(x) (QString(":/") + x)     //只读资源路径转换
#define FIXRESOURCEURL_R(x) (QString("qrc:/") + x)   //只读资源URL转换



#else

#define FIXLOCALPATH_R(x) x            //只读本地文件路径
#define FIXLOCALPATH_W(x) x            //读写本地文件路径

#define FIXRESOURCEPATH_R(x) (QString(":/") + x)     //只读资源路径转换
#define FIXRESOURCEURL_R(x) (QString("qrc:/") + x)   //只读资源URL转换



#endif


#endif // PLATFORM_H
